import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestCallable2 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CallableThread callableThread = new CallableThread();
        FutureTask futureTask = new FutureTask<>(callableThread);
        new Thread(futureTask).start();
        System.out.println("主线程先做其他重要的事情");
        if(!futureTask.isDone()){
            //继续做其他事情
            System.out.println(6);
        }
        System.out.println(futureTask.get());
    }
}

class CallableThread implements Callable{

    /**
     * Computes a result, or throws an exception if unable to do so.
     *
     * @return computed result
     * @throws Exception if unable to compute a result
     */
    @Override
    public Object call() throws Exception {
        Thread.sleep(1000);
        System.out.println(Thread.currentThread().getName());
        return "wmin";
    }
}
